from typing import *
from math import inf
class Solution:
    def flipgame(self, fronts: List[int], backs: List[int]) -> int:
        s = set()
        for f,b in zip(fronts,backs):
            if f == b:
                s.add(f)
        a = inf
        for f,b in zip(fronts,backs):
            if f not in s:
                a = min(f,a)
            if b not in s:
                a = min(b,a)
        return 0 if a == inf else a